(function(){"use strict";let l;const u=new Uint8Array(16);function m(){if(!l&&(l=typeof crypto!="undefined"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!l))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return l(u)}const o=[];for(let t=0;t<256;++t)o.push((t+256).toString(16).slice(1));function I(t,e=0){return o[t[e+0]]+o[t[e+1]]+o[t[e+2]]+o[t[e+3]]+"-"+o[t[e+4]]+o[t[e+5]]+"-"+o[t[e+6]]+o[t[e+7]]+"-"+o[t[e+8]]+o[t[e+9]]+"-"+o[t[e+10]]+o[t[e+11]]+o[t[e+12]]+o[t[e+13]]+o[t[e+14]]+o[t[e+15]]}const r={randomUUID:typeof crypto!="undefined"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function g(t,e,n){if(r.randomUUID&&!e&&!t)return r.randomUUID();t=t||{};const a=t.random||(t.rng||m)();if(a[6]=a[6]&15|64,a[8]=a[8]&63|128,e){n=n||0;for(let i=0;i<16;++i)e[n+i]=a[i];return e}return I(a)}const c={getItem(t){let e=JSON.parse(window.localStorage.getItem(t));return e?e.expireTime<=Date.now()?(window.localStorage.removeItem(t),null):e.data:null},setItem(t,e,n=30*60*60*1e3){let a={data:e};n&&(a.expireTime=Date.now()+n),window.localStorage.setItem(t,JSON.stringify(a))},removeItem(t){window.localStorage.removeItem(t)},clear(){window.localStorage.clear()}},v=t=>new Promise((e,n)=>{const a=document.createElement("script");a.src=t,a.async=!0,a.onload=e,a.onerror=i=>n(new Error(`Failed to load: ${t}`,{cause:i})),document.head.appendChild(a)}),d=864e5,p="liveIntentData",_={appId:null,apolloAnonId:null,liveIntentData:{},onLoad:async function({appId:t}){this.appId=t,this.host="https://aplo-evnt.com/api/v1/intent_pixel/track_request",this.canTrackUrl="https://aplo-evnt.com/api/v1/intent_pixel/can_track_visitor",this.apolloAnonId=localStorage.getItem("apolloAnonId"),this.apolloAnonId||(this.apolloAnonId=this.generateApolloAnonId(),localStorage.setItem("apolloAnonId",this.apolloAnonId)),this.canTrack=await this.canTrackApiCall(),this.canTrack&&await this.loadAndGetLiveIntentData();let e=location.href;await this.sendPageVisitEvent(window.location.href);let n=this;document.body.addEventListener("click",()=>{requestAnimationFrame(()=>{e!==location.href&&(e=location.href,n.sendPageVisitEvent(e))})},!0)},sendPageVisitEvent:async function(t){const e={apollo_anon_id:this.apolloAnonId,event_type:"page_visit",page:t},n=JSON.parse(localStorage.getItem(`${this.appId}_eventQueue`))||[];n.push(e),localStorage.setItem(`${this.appId}_eventQueue`,JSON.stringify(n)),this.batchProcessEvents()},batchProcessEvents:async function(){var i,h;const t=JSON.parse(localStorage.getItem(`${this.appId}_eventQueue`))||[],e=1,n=100;let a=[];for(;t.length>=e&&a.length0)try{await this.sendEvents(a),localStorage.setItem(`${this.appId}_eventQueue`,JSON.stringify(t.slice(a.length)))}catch(s){console.log("ERROR",s)}},sendEvents:async function(t){await fetch(`${this.host}?app_id=${this.appId}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},canTrackApiCall:async function(){try{const t=c.getItem(`${this.appId}_canTrack`);if(t)return t;const n=await(await fetch(`${this.canTrackUrl}?x_app_id=${this.appId}`)).json();return c.setItem(`${this.appId}_canTrack`,n.can_track,d),n.can_track}catch(t){return console.log("ERROR",t),!1}},loadAndGetLiveIntentData:async function(){var t;try{const e=c.getItem(p);if(e){this.liveIntentData=e;return}else await v("https://d-code.liadm.com/did-0091.min.js"),(t=window.liQd_did_0091)!=null&&t.resolve&&window.liQd_did_0091.resolve(n=>{this.liveIntentData={email_md5:n.md5,email_sha2:n.sha2},c.setItem(p,this.liveIntentData,d)},n=>{console.error("LiveIntent resolve error:",n)},{qf:"0.1",resolve:["md5","sha2","nonId"]})}catch(e){console.log("ERROR",e)}},generateApolloAnonId:function(){return g()}};window.trackingFunctions=_})();